import { makeObservable, observable, action } from 'mobx'

class Todo {
  // 定义仓库数据
  id = Math.random()
  title = ''
  finished = false

  constructor() {
    // 响应式处理
    makeObservable(this, {
      title: observable,
      finished: observable,
      toggle: action
    })
  }

  toggle() {
    this.finished = !this.finished
  }
}

const TodoStore = new Todo()

export default TodoStore
